<?php

session_start();

$video_id = $_GET['video_id'];
$tagToRemove = $_GET['tagToRemove'];

include('../../../sidebardbinfo-live.php');

// connect to the database
$removetaglink = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$removetaglink) {
	die('Problem connecting to database server : ' . mysql_error());
}

// make $dbname the current db
$removetagdb_selected = mysql_select_db($dbname, $removetaglink);
if (!$removetagdb_selected) {
	die ('Problem connecting to database : ' . mysql_error());
}

// get the word_id from the keywords table
$getwordidstmt = "SELECT word_id FROM tags_keywords WHERE word='".addslashes($tagToRemove)."'";
$getwordidres = mysql_query($getwordidstmt);
if (!$getwordidres) {
	die ('Problem with query : ' . mysql_error());
}

$word_id = mysql_result($getwordidres,0);

$deletelookupstmt = "DELETE FROM tags_lookup WHERE video_id = '".$video_id."' AND word_id = '".$word_id."'";
$deletelookupres = mysql_query($deletelookupstmt);
if (!$deletelookupres) {
	die ('Problem with query : ' . mysql_error());
}

mysql_close($removetaglink);
?>